﻿using AspNetDemo.Models;
using AspNetDemo.Services;
using NHibernate;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace AspNetDemo.App_Start
{
    public class InitData
    {
        public static void Init()
        {
            using (ISession session = SessionHelper.Instance.GetSession())
            {
                using (ITransaction transaction = session.BeginTransaction(System.Data.IsolationLevel.ReadCommitted))
                {
                    var stus = new List<Student>();
                    stus.Add(new Student() { Name = "张三" });
                    stus.Add(new Student() { Name = "李四" });
                    stus.Add(new Student() { Name = "王五" });
                    stus.Add(new Student() { Name = "赵六" });

                    stus.ForEach(x => session.Save(x));
                    transaction.Commit();
                }
            }
        }
    }
}